package people;

import blackjack.Hand;

public class Player extends Person{
    private int money = 0;   //玩家总资产
    private String id = "007";      //玩家id
    private int bet = 0;     //当前下的赌注

    public Player() {
        // 私有化无参构造函数
    }

    public Player(String id, int money) {    //生成函数
        this.money = money;
        this.id = id;
        this.bet = 0;
        this.hand = new Hand();
        this.bestPoint = 0;
        this.busted = false;
    }

    public String getID() {              //获取玩家id
        return this.id;
    }

    public int getMoney() {           //获取余额
        return this.money;
    }

    public void addMoney(int num) {   //增加余额
        this.money += num;
    }

    public void loseMoney(int num) {   //减少余额
        this.money -= num;
    }

    public int getBet() {           //获取赌注数量
        return this.bet;
    }           //获取赌注

    public int addBet(int num) {   //增加赌注（会扣钱），不足返回1
        if(money>=num && num>0){
            this.bet += num;
            loseMoney(num);
            return 0;
        }
        else {
//            System.out.println("玩家"+this.id+"余额不足，无法下注！");
            return 1;
        }
    }

    public void emptyBet() {        //清空赌注
        this.bet = 0;
    }

}
